<template>
  <div id="app">
    <div class="detail-body">
      <div class="detail-body-left">
        <div class="detail-body-main">
          <div>
            <div style="align-items: stretch" class="log-add">
              <span class="avatar">
                <el-avatar :size="30"> in </el-avatar>
              </span>
              <div
                class="mix-content"
                style="flex: 1 1 0%; line-height: 33px"
                @click="unfoldFollowPanel"
                v-if="!isFollowPanelOpen"
              >
                <div class="i-cont unfold">
                  <span>写跟进...</span>
                </div>
              </div>
              <div
                class="log-content"
                v-if="isFollowPanelOpen"
                :class="{ 'log-content--expanded': isFollowPanelOpen }"
              >
                <div class="mix-content">
                  <el-form label-position="top">
                    <el-form-item label="跟进内容">
                      <el-input
                        type="textarea"
                        v-model="followData.followupContent"
                      />
                    </el-form-item>
                    <div class="form-container">
                      <el-form-item label="下次联系时间" style="width: 50%">
                        <el-date-picker
                          v-model="followData.nextTime"
                          class="custom-date-picker"
                          type="datetime"
                          style="width: 100%"
                          format="YYYY-MM-DD HH:mm:ss"
                          value-format="YYYY-MM-DD HH:mm:ss"
                        />
                      </el-form-item>
                      <el-form-item label="跟进方式" style="width: 50%">
                        <el-select v-model="followData.followupMethod">
                          <el-option label="打电话" value="1"></el-option>
                          <el-option label="发邮件" value="2"></el-option>
                          <el-option label="发短信" value="3"></el-option>
                          <el-option label="见面拜访" value="4"></el-option>
                          <el-option label="活动" value="5"></el-option>
                        </el-select>
                      </el-form-item>
                    </div>
                    <div class="file-content">
                      <div class="control-item">
                        <el-icon><PictureFilled /></el-icon>
                      </div>
                      <div class="control-item">
                        <el-icon><Folder /></el-icon>
                      </div>
                    </div>
                    <div class="send-bar">
                      <el-button type="primary" color="#0052CC" @click="save">
                        发布
                      </el-button>
                      <el-button @click="unfoldFollowPanel">取消</el-button>
                    </div>
                  </el-form>
                </div>
              </div>
            </div>
          </div>
          <div class="log">
            <div class="log-filter">
              <div class="filter-left">
                <span class="filter-text"> 显示： </span>
                <el-button color="#0052CC">跟进记录</el-button>
                <el-button>线索动态</el-button>
              </div>
              <div class="filter-right">
                <el-button :icon="filterIcon">筛选</el-button>
              </div>
            </div>
            <p style="text-align: center; margin-top: 8px">没有更多了</p>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script setup>
import { ref } from 'vue'
import { PictureFilled, Folder } from '@element-plus/icons-vue'
import filterIcon from '@/assets/font/filterIcon.vue'
import { saveFollowup } from '@/api/followup'

const isFollowPanelOpen = ref(false)
const followData = ref({})
const props = defineProps({
  data: {
    type: Object,
    required: true,
  },
})

console.log(props.data)

function unfoldFollowPanel() {
  isFollowPanelOpen.value = !isFollowPanelOpen.value
  followData.value = {}
}

function save() {
  followData.value.followupType = props.data.type
  followData.value.followupOptionId = props.data.leadsNo
  console.log(followData.value)
  saveFollowup(followData.value).then(() => {
    unfoldFollowPanel()
  })
}
</script>
<style scoped>
.detail-body {
  display: flex;
}

.detail-header-subtitle {
  color: #6b778c;
  font-size: 14px;
  margin-bottom: 2px;
}

.detail-header-body {
  align-items: center;
  display: flex;
  justify-content: space-between;
  text-align: left;
  width: 100%;
  flex-direction: row;
}

.detail-header-left,
.detail-header-right {
  align-items: center;
  display: flex;
}

.drawer-btn {
  width: 32px;
  height: 30px;
}

.detail-header-title {
  display: flex;
  font-size: 24px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
}

.focus-icon {
  color: #dfe1e6;
  cursor: pointer;
  font-size: 18px;
  font-weight: 700;
  margin-left: 16px;
}

.detail-base {
  margin: 12px 0 0;
  width: auto;
  position: relative;
}

.base-item {
  align-items: center;
  display: flex;
  min-height: 24px;
  overflow: hidden;
}

.base-title {
  color: #6b778c;
  margin-right: 8px;
  font-size: 14px;
}

.text-one-line {
  overflow: hidden;
  text-overflow: ellipsis;
}

.tags-content {
  margin-top: 8px;
}

.tag-view {
  display: flex;
  flex-wrap: wrap;
}

.tag-referene {
  border: none;
  width: 14px;
  height: 14px;
  padding: 2px;
}

.detail-body-left {
  flex: 1;
  min-width: 20px;
  width: 0;
}

.detail-body-main {
  height: auto;
  margin: 16px 8px;
  border-radius: 12px;
  padding: 16px;
  background-color: #fff;
  box-shadow: 0 2px 8px #172b4d1a;
  overflow: hidden;
}

.avatar {
  display: inline-block;
  position: relative;
  flex-shrink: 0;
  margin-right: 8px;
  margin-top: 5px;
}

.log-add {
  align-items: center;
  display: flex;
  text-align: left;
  width: 100%;
}

.log-content {
  flex: 1;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease-out;
}

.log-content--expanded {
  max-height: 500px; /* Adjust this value based on your content height */
}

.log-content .mix-content {
  padding: 8px 16px 24px;
}

.form-container {
  display: flex;
  text-align: left;
  width: 100%;
  justify-content: space-between;
  align-items: flex-start;
  flex-direction: row;
  gap: 24px;
}

.file-content {
  display: flex;
}

.control-item {
  margin-right: 20px;
}

.send-bar {
  margin-top: 16px;
}

.mix-content {
  color: #7a869a;
  cursor: text;
  padding: 0;
  border: 1px solid #dfe1e6;
  border-radius: 4px;
  /* padding: 8px 16px 24px; */
  position: relative;
  flex-direction: row;
}

.i-cont {
  line-height: 40px;
  padding: 0 24px;
}

.log {
  margin-top: 40px;
  position: relative;
}

.log-filter {
  height: 40px;
  width: 100%;
  align-items: center;
  display: flex;
  text-align: left;
  flex-direction: row;
  justify-content: space-between;
}

.filter-left {
  width: unset;
}

.filter-text {
  font-size: 14px;
}

.filter-right {
  align-items: center;
  display: flex;
  justify-content: flex-end;
}
</style>
